// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Author: Markus Gutschke

#ifndef CHECK_H__
#define CHECK_H__

// Output a error message and exit program with a non-zero return code.
void fatal(const char *fmt, ...) __attribute__((format(printf, 1, 2),
                                                noreturn));
#ifndef NDEBUG
#define check(x) do {                                                         \
                   if (!(x))                                                  \
                     fatal("Check failed at "__FILE__":%d in %s(): %s",       \
                            __LINE__, __func__, #x);                          \
                 } while (0)
#else
#define check(x) do {                                                         \
                   if (!(x))                                                  \
                     fatal("Fatal error!\n");                                 \
                 } while (0)
#endif

#endif  // CHECK_H__
